package com.example.demo.timer;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @desc: <br/>
 * @author: Jingbo Hu<br/>
 * @time：2021年06⽉17⽇<br/>
 * @version：v1.0.0<br>
 */
public class QuartzTask implements Job {

    // 任务类不能直接注入Bean，若想注入Bean需要配置第4步
    @Autowired
    private QuartzTaskService service;

    private void before() {
        System.out.println("定时任务开始");
    }

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        service.handle();
        System.out.println("hello quartz");
    }

    private void afer() {
        System.out.println("定时任务结束");
    }
}
